kubectl create ns kubecost
wget https://raw.githubusercontent.com/kubecost/cost-analyzer-helm-chart/master/kubecost.yaml
調整一下yaml
# Source: cost-analyzer/charts/prometheus/templates/server-pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
labels:
component: "server"
app: prometheus
release: kubecost
chart: prometheus-11.0.2
heritage: Helm
name: kubecost-prometheus-server
spec:
storageClassName: nfs-client
accessModes:
- ReadWriteOnce
resources:
requests:
storage: "32Gi"
---
# Source: cost-analyzer/templates/cost-analyzer-pvc-template.yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: kubecost-cost-analyzer
labels:
app.kubernetes.io/name: cost-analyzer
helm.sh/chart: cost-analyzer-1.86.1
app.kubernetes.io/instance: kubecost
app.kubernetes.io/managed-by: Helm
app: cost-analyzer
spec:
storageClassName: nfs-client
accessModes:
這邊不修改的話,container要不到pv可能就會處在pending的狀態唷
kubectl apply -f kubecost.yaml --namespace kubecost
kubectl port-forward svc/kubecost-cost-analyzer 9090:9090 -n kubecost
可以看到針對Kubernetes的各種資源有做初步的經費預估(cpu/memory/storage)
看起來我這邊主要的花費計算是都在cpu idle cost上面QQ
點ithomelab namespace進去看看,可以發現有在針對pod做效率評分(efficiency)與計價
下面還有針對resource request/limit的意見,看起來有沒有設定request/limit是會影響很大的計費根據......
這邊有教你如何省錢,他叫我drain掉一個node......(orz
就體驗到這吧,看了一下文件這邊的analyzer model應該都是可以替換的只是要研究一下。homelab談到錢太傷腦了,我決定快速跳過這個章節了
原本是很猶豫要不要寫這篇的,因為有聽說目前算起來還不是非常的準確(實務上有很多東西無法被算到),而且要定價model也是很商業化複雜的事情,但想想還是裝起來看看好了畢竟工作好像就是跟$脫離不了關係,在所有東西都要量化的時代也許能是一個選擇。